package trying.ReferenceType;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * 引用类型的值传递，实现对象的深拷贝
 */
public class TestReference {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        List<Person> list = new ArrayList<>();
        Person person = new Person("yang","24");
        list.add(person);
        List<Person> list2 = new ArrayList<>();
        list.get(0).setAge("25");
        //深度拷贝，通过序列化对象，可以实现引用类型的值传递
        Person person1 = (Person) person.deepClone();
        person1.setName("ju");
        list2.add(person1);
        System.out.println(list.toString());
        System.out.println(list2.toString());
    }
}
